package com.zhaungwei.weather.controller;

import com.zhaungwei.weather.service.WeatherDataService;
import com.zhaungwei.weather.vo.WeatherResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author LeviCoder
 * @create 2019-03-21 0:47
 */
@RestController
@RequestMapping("/weather")
public class WeatherController {

    @Autowired
    private WeatherDataService weatherDataService;

    @GetMapping("/city/{city}")
    public WeatherResponse city(@PathVariable("city") String city){
        return weatherDataService.getDataByCity(city);
    }

    @GetMapping("/citykey/{citykey}")
    public WeatherResponse citykey(@PathVariable("citykey") String citykey){
        return weatherDataService.getDataBycitykey(citykey);
    }
}
